//
//  jiedaiController.m
//  PASystem
//
//  Created by michael on 16/8/15.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "jiedaiController.h"

@interface jiedaiController ()
@property(nonatomic,strong)NSMutableArray * dataArray;
@property(nonatomic,strong)NSDictionary * dic;

@end

@implementation jiedaiController

- (void)viewDidLoad {
    [super viewDidLoad];
//     UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
//    
//    self.tableView.layer.borderWidth = 10;
//    self.tableView.layer.borderColor = [myColor CGColor];

//     self.tableView   .userInteractionEnabled = NO;
//    [ self.tableView setScrollEnabled:NO];
self.tableView.bounces = NO;
     self.title = _string;
    self.view.backgroundColor = [UIColor whiteColor];
            [self loadData]; //加载网络数据
}
-(NSMutableArray*)dataArray{
    if (_dataArray == nil) {
      _dataArray =   [NSMutableArray array];
    }
    return _dataArray;
}
#pragma mark 加载网络数据
-(void)loadData{
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
    
 NSString *json =[NSString stringWithFormat: @"{'action':%@,'service': %@, 'userName':'%@','password':'%@', 'vaueJson':'{userid :%@,id:%@}'}",_action,_service,userId,pwdId,userHumber,_id];
     NSArray * array = @[@{@"arg0":json}];
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {

       
     NSDictionary *dic = JSON[@"reason"];
        
    NSDictionary *dict = dic[@"attrs"];
    NSLog(@"%@",dict);
    
    _dic = dict;
    [_dataArray addObject:dict];
    

     NSLog(@"11%@",_dataArray);
        
        [self.tableView reloadData];
            
    } failure:^(NSError *error) {
     [self.tableView headerEndRefreshing];
        
    }];
 
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  16;
}
#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row ==0) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"标题:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"TITLENAME"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
if (indexPath.row ==1) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"人数:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text =[NSString stringWithFormat:@"%@",_dic[@"PNUMBER"]];
//    _dic[@"WSNAME"];
      label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
if (indexPath.row ==2) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"来访目的:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"OBJECTIVE"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==3) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"全陪:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"ACCOMPANY"];
     label2.font = [UIFont systemFontOfSize:12];
           label2.textAlignment = NSTextAlignmentRight;

    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==4) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"来杭情况:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"THECOME"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==5) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"离杭情况:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"THEGO"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==6) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"会见地点:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"MEETPLACE"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==7) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"会见领导:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"MEETLEADER"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==8) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"会见时间:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
  
   //时间
  NSString *string = _dic[@"MEETTIME"];
  NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    fmt.dateFormat = @"MMM d, yyyy HH:mm:ss aa";
 fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"];
     NSDate *date = [fmt dateFromString:string];
     NSDateFormatter *fm = [[NSDateFormatter alloc] init];
    fm.dateFormat = @"yyyy-MM-dd";
     NSString *selfYear = [fm stringFromDate:date];
      label2.textAlignment = NSTextAlignmentRight;

    label2.text = selfYear;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==9) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"联系人:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"CONTACTS"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==10) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"电话:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"TEL"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
if (indexPath.row ==11) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"传真:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"FOX"];
          label2.textAlignment = NSTextAlignmentRight;

     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}if (indexPath.row ==12) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"会谈内容:";
                 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"CONTENT"] font:12 minsWidth: 120];
  if (titleSize<44) {
    titleSize =  cell.height;
}else{
titleSize = titleSize;

}
    
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120,titleSize)];
    label2.text = _dic[@"CONTENT"];
          label2.textAlignment = NSTextAlignmentRight;
label2.numberOfLines = 0;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
if (indexPath.row ==13) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"参会人员:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, label.height)];
    label2.text = _dic[@"PARTICIPANTS"];
          label2.textAlignment = NSTextAlignmentRight;
label2.numberOfLines = 0;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
if (indexPath.row ==14) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"其它安排:";
             CGFloat titleSize = [OAToolBox sizebyText:_dic[@"CODE"] font:12 minsWidth: 120];
  if (titleSize<44) {
    titleSize =  cell.height;
}else{
titleSize = titleSize;

}
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, titleSize)];
    label2.text = _dic[@"CODE"];
          label2.textAlignment = NSTextAlignmentRight;
label2.numberOfLines = 0;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, cell.contentView.height)];
    label.text = @"备注:";
         CGFloat titleSize = [OAToolBox sizebyText:_dic[@"REMARKS"] font:12 minsWidth: 120];
  if (titleSize<44) {
    titleSize =  cell.height;
}else{
titleSize = titleSize;

}
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top,KScreenWidth -120, titleSize)];
    label2.text = _dic[@"REMARKS"];
          label2.textAlignment = NSTextAlignmentRight;
label2.numberOfLines = 0;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
}

- (void)viewDidAppear:(BOOL)animated
{
self.tableView.frame = CGRectMake(0, 64, KScreenWidth, KScreenHeight-46-64);
     UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
    
    self.tableView.layer.borderWidth = 10;
    self.tableView.layer.borderColor = [myColor CGColor];

}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat H = 44;
if (indexPath.row == 15){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"REMARKS"] font:12 minsWidth:120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}

else if (indexPath.row ==14){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"CODE"] font:12 minsWidth:120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}

else if (indexPath.row ==13){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"PARTICIPANTS"] font:12 minsWidth:120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}

else if (indexPath.row ==12){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"CONTENT"] font:12 minsWidth:120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}

else{

return H;
}

}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
